
import * as mobx from 'mobx';
import * as WORKFLOW_SHARE from '../apis/share';
import {message} from 'antd';
import { WeaLocaleProvider } from 'ecCom';

const {observable, action} = mobx;
const getLabel = WeaLocaleProvider.getLabel;

export class WFShareBatchStore {

    @observable addShareVisible = false;    //添加共享Modal
    @observable datas = [];
    @observable selectedRowKeys = [];  //标记选择的index

    constructor() {
        this.toogleAddShare = this.toogleAddShare.bind(this);
        this.addShare = this.addShare.bind(this);
        this.setDatas = this.setDatas.bind(this);
        this.setSelectedRowKeys = this.setSelectedRowKeys.bind(this);
    }

    @action

    setDatas (params = []){
        this.datas = params;
    }

    setSelectedRowKeys (params = []){
        this.selectedRowKeys = params;
    }

    addShare (params = {}) {
        message.loading(getLabel(383498,'正在添加...请稍候'),0);
        WORKFLOW_SHARE.doWorkflowAddShareBatch(params).then((data) => {
            if(data.api_status){
                message.destroy();
                message.success(getLabel(83880,'添加成功'));
            }else{
                message.destroy();
                message.error(getLabel(26772,'添加失败'));
            }
        },()=>{
            message.destroy();
            message.error(getLabel(26772,'添加失败'));
        })
    }

    toogleAddShare (visible = false) {
        this.addShareVisible = visible;
    }
}